﻿using System;
using InspectionMAC.SystemThread;

namespace InspectionMAC.Config
{
    public static class StationEventHandler
    {
        private static string _currentSampleId = "";
        private static DateTime _lastUpdateTime = DateTime.MinValue;

        // 工位1调用：设置当前物料ID
        public static void OnSampleEnterStation1(string sampleId)
        {
            _currentSampleId = sampleId;
            _lastUpdateTime = DateTime.Now;
        }

        // 工位2/3调用：获取当前物料ID
        public static string GetCurrentSampleId()
        {
            // 有效期为2秒，防止使用过期ID
            if ((DateTime.Now - _lastUpdateTime).TotalSeconds > 10)
            {
                return string.Empty;
            }
            return _currentSampleId;
        }

        // 完成检测后调用
        public static void OnSampleComplete()
        {
            _currentSampleId = string.Empty;
        }
    }
}